<?php
if (isset($InputData['topic_id'])) {
    if (!isset($InputData['work_list_type'])) {
        //获取页面视图
        //连接专题数据模型
        require_once("{$CfgPara->root}/model/topic.m.php");
        //获取专题信息
        $myTopic = new topic_m($CfgPara->database);
        $topicMsg = $myTopic->topic_msg($InputData['topic_id']);
        if (is_string($topicMsg)) {
            echo($topicMsg);
            goto page_end;
        } else {
            $topicImg = make_img_name::make_img_micro_name($topicMsg->Picture);
            //判断当前用户是否已推荐 如果没有参与 则使用镂空的图标 后缀加-o
            $isRecommend = $myTopic->topic_recommend_check($topicMsg->Id);
            if ($isTablet === TRUE && isset($_SESSION['user_id'])) {
                //如果为平板或PC 需要当前用户加入专题的数量
                $workCount = $myTopic->topic_work_count($_SESSION['user_id'], $topicMsg->Id);
            } else {
                $workCount = 0;
            }
            //连接视图
            require("{$viewRoot}topic_show{$viewEx}");
            require_once("{$CfgPara->root}/model/work.m.php");
            //连接作品列表
            $InputData['list_type'] = work_m::ListTopicOK;
            require("{$CfgPara->root}/controller/works_list.c.php");

            //连接右侧栏菜单
            if ($isTablet === false)
                require("{$CfgPara->root}/view/menu_r_topic_show.app.v.php");
        }
    } else {
        //连接专题数据模型
        require_once("{$CfgPara->root}/model/topic.m.php");
        //获取专题信息
        $myTopic = new topic_m($CfgPara->database);
        $topicMsg = $myTopic->topic_msg($InputData['topic_id']);
        if (is_string($topicMsg)) {
            echo($topicMsg);
            goto page_end;
        }
        //仅获取专题页面中的作品页面
        require_once("{$CfgPara->root}/model/work.m.php");
        $InputData['page_change'] = 1; //仅页面内容 第一页
        if ($InputData['work_list_type'] == 1) {
            $InputData['list_type'] = work_m::ListTopicOK;
        } elseif ($InputData['work_list_type'] == 2) {
            $InputData['list_type'] = work_m::ListTopicOKHot;
        } elseif ($InputData['work_list_type'] == 3) {
            $InputData['list_type'] = work_m::ListTopicOKRecommend;
        } else {
            echo '作品列表类型不支持';
            goto page_end;
        }
        require("{$CfgPara->root}/controller/works_list.c.php");
    }
}

page_end:;